﻿import QtQuick 2.9
import QtQuick.Window 2.2

Window {
    id: win
    visible: true
    width: _LS*_IMGWidth
    height: _HS*_IMGWidth
    title: qsTr("Life Game")
    objectName: "myQml"

    /*
    gzh: 格子行
    gzl: 格子列
    value: 格子值
    */
    //    function setStatus(gzh, gzl, value)
    //    {
    //        console.log("qml ",gzh, gzl, value)
    //    }

    property int  _HS: 20
    property int  _LS: 60

    property int  _IMGWidth: 30

    property int gzh: hang
    property int gzl: lie
    property var nameValue: value1

    property int nameFlag: flag


    onNameFlagChanged: {
//        console.log("qml ",gzh, gzl, nameValue)
        if(array.length < _HS * _LS)
        {
            return
        }
        array[gzh*_LS+gzl].visible = nameValue===49?true:false
    }

    Component{
        id: com
        Image {
            source: "qrc:/ball.png"
        }
    }

    property var array: new Array

    Component.onCompleted:
    {
        for(var i=0; i<_HS; i++)
        {
            for(var j=0;j<_LS; j++)
            {
//                var obj = Qt.createComponent(com).createObject(win)
                var obj = com.createObject(win)
                obj.x = j*_IMGWidth
                obj.y = i*_IMGWidth
                array.push(obj)
            }
        }
    }

}
